#include"process.h"
#include<string.h>
#include<unistd.h>
#define NUM 100
#define status '='
#define point '.'

void process(double total,double current)
{
    double rate=current/total;
    double precent=rate*100;
    size_t loading=(size_t) precent;
    char bar[NUM+1];
    char points[6];
    memset(bar,'\0',sizeof(bar));
    memset(points,'\0',sizeof(points));
    
    static size_t time=0;
    time=(time%6)+1;
    for(int i=0;i<6;i++)
    {
        if(i<time)
        {
            points[i]=point;
        }
        else
        {
            points[i]=' ';
        }
    }


    for(int i=0;i<=precent;i++)
    {
        bar[i]=status;
    }
    printf("[%-100s][%.1lf][%s]\r",bar,precent,points);
}
//void process()
//{
//    char bar[NUM+1];
//    memset(bar,'\0',NUM);
//    int cnt=0;
//    while(cnt<=NUM)
//    {
//        if(cnt!=NUM)
//            bar[cnt]='>';
//        printf("[%-100s][%d\%]\r",bar,cnt);
//        fflush(stdout);
//        usleep(100000);
//        bar[cnt]=status;
//        cnt++;
//    }
//    printf("\n");
//}
